//
//  ContactDetailViewController.h
//  cliqset
//
//  Created by David Hinson on 2/11/09.
//  Copyright 2009 Sumner Systems Management, Inc.. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "Contact.h"

@interface ContactDetailViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UIActionSheetDelegate> {
	
	NSInteger index;

	UITableView *contactDetailTable;
	
	// -- Personal Cells
	NSMutableArray *personalPhoneCells;
	NSMutableArray *personalEmailCells;
	NSMutableArray *personalURLCells;
	NSMutableArray *personalIMCells;
	NSMutableArray *personalAddressCells;
	
	// -- Professional Cells
	NSMutableArray *professionalPhoneCells;
	NSMutableArray *professionalEmailCells;
	NSMutableArray *professionalURLCells;
	NSMutableArray *professionalIMCells;
	NSMutableArray *professionalAddressCells;
	
	UILabel *myName;
	UILabel *myJob;
	
	UIButton *addToFavesBtn;
	UIButton *editUserBtn;
	UIButton *deleteContactBtn;
	
	BOOL isPersonal;
	BOOL isFavorite;	
	BOOL isEditing;
	
	Contact * bufferContact;
	
	int personalCellsCount;
	int professionalCellsCount;
	
	NSTimer* viewTimer;
	
	UIView *header;
	UIView *footer;
	
	UIBarButtonItem* editButton;
	UIBarButtonItem* saveButton;
	UIBarButtonItem* cancelButton;
}

@property (retain, nonatomic) UIView *header;
@property (retain, nonatomic) UIView *footer;

@property NSInteger index;
@property (nonatomic, retain) IBOutlet UITableView *contactDetailTable;

@property (nonatomic, retain) NSMutableArray *personalPhoneCells;
@property (nonatomic, retain) NSMutableArray *personalEmailCells;
@property (nonatomic, retain) NSMutableArray *personalURLCells;
@property (nonatomic, retain) NSMutableArray *personalIMCells;
@property (nonatomic, retain) NSMutableArray *personalAddressCells;

@property (nonatomic, retain) NSMutableArray *professionalPhoneCells;
@property (nonatomic, retain) NSMutableArray *professionalEmailCells;
@property (nonatomic, retain) NSMutableArray *professionalURLCells;
@property (nonatomic, retain) NSMutableArray *professionalIMCells;
@property (nonatomic, retain) NSMutableArray *professionalAddressCells;

@property (nonatomic, retain) UIButton *addToFavesBtn;
@property (nonatomic, retain) UIButton *editUserBtn;
@property (nonatomic, retain) UIButton *deleteContactBtn;

@property (nonatomic, retain) UILabel *myName;
@property (nonatomic, retain) UILabel *myJob;

@property BOOL isEditing;
@property BOOL isFavorite;
@property BOOL isPersonal;

@property int personalCellsCount;
@property int professionalCellsCount;

@property (nonatomic, retain) Contact *bufferContact;

@property (nonatomic, retain) NSTimer *viewTimer;

@property (nonatomic, retain) UIBarButtonItem* editButton;
@property (nonatomic, retain) UIBarButtonItem* saveButton;
@property (nonatomic, retain) UIBarButtonItem* cancelButton;

-(void)doTableFooter;
-(void)doTableHeader;
-(void)loadAllSections;
-(int)sectionCount:(int)section;
- (void)showDeleteContactButton:(BOOL)show;
- (void)showFavesButton:(BOOL)show;
- (void)showEditButton:(BOOL)show;

-(void)resetTimer;
-(void)doEdit:(id)id;

@end

// My cells
@interface ContactCell : NSObject
{
@private	
	NSMutableString *_label;
	NSMutableString *_content;
	NSMutableString *_type;
	int              _tag;
	int              _elementIndex;
}

@property (nonatomic, retain) NSMutableString *label;
@property (nonatomic, retain) NSMutableString *content;
@property (nonatomic, retain) NSMutableString *type;
@property int tag;
@property int elementIndex;

-(id)init;
-(void)dealloc;

@end

